package com.freshcity.page.zhitiao
{
	import com.freshcity.component.BaseGameObject;
	import com.freshcity.component.container.Component;
	import com.freshcity.core.MainScene;
	import com.freshcity.graphics.ZhiTiaoBoxWin;
	import com.freshcity.manager.LayerManager;
	
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	public class ZhiTiaoBox extends BaseGameObject
	{
		private var win:ZhiTiaoBoxWin;
		
		override public function initialize():void
		{
			super.initialize();
			
			win=new ZhiTiaoBoxWin();
			
			LayerManager.sceneLayer.centerPopup(win);
			parent.addChild(win);
			
			win.closeBtn.addEventListener(MouseEvent.CLICK,onCloseBtn);
			//win.refreshBtn.addEventListener(MouseEvent.CLICK,onRefreshData);
			//group.commu.register(OpCodes.START_TALK, onStartTalk);
			//group.commu.register(OpCodes.WAIT_TALK, onWaitTalk);
		}
		
		protected function onCloseBtn(event:MouseEvent):void
		{
			win.closeBtn.removeEventListener(MouseEvent.CLICK,onCloseBtn);
			parent.removeChild(win);
		}
		
		public function show(data:*):void
		{
			var roomBox:Sprite = new Sprite();
			
			var s:ZhiTiaoInfo;
			var xpos:int=10;
			var ypos:int;
			
			for each (var room:* in data)
			{
				if(group.user.level >= room.grade){
					s=new ZhiTiaoInfo(room, xpos,ypos);
					s.owner=this;
					roomBox.addChild(s);
					ypos+=80;
				}
			}
			win.panel.source = roomBox;
		}		
		
	}
}